<html>
<head><meta charset="utf-8"><title>using the vscode lldb debugger with the cargo test suite · t-cargo · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/index.html">t-cargo</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/using.20the.20vscode.20lldb.20debugger.20with.20the.20cargo.20test.20suite.html">using the vscode lldb debugger with the cargo test suite</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="226286015"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/using%20the%20vscode%20lldb%20debugger%20with%20the%20cargo%20test%20suite/near/226286015" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Brendan Cully <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/using.20the.20vscode.20lldb.20debugger.20with.20the.20cargo.20test.20suite.html#226286015">(Feb 14 2021 at 04:55)</a>:</h4>
<p>Apologies if this is the wrong place for this question, I genuinely can't tell.<br>
I'm playing around with the cargo test suite in VSCode's debugger (using CodeLLDB) and can't figure out how to get it to break inside the actual core cargo code. It looks like it's because tests generally fork a child process with e.g., p.run(), and lldb doesn't seem to follow the fork. I assume I'm missing something silly - does anyone have a clue handy?</p>



<a name="226293661"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/using%20the%20vscode%20lldb%20debugger%20with%20the%20cargo%20test%20suite/near/226293661" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/using.20the.20vscode.20lldb.20debugger.20with.20the.20cargo.20test.20suite.html#226293661">(Feb 14 2021 at 08:46)</a>:</h4>
<p>Lldb doesn't support debugging child processes. Gdb does when you use <code>set follow-fork-mode child</code> before the fork.</p>



<a name="226313813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/using%20the%20vscode%20lldb%20debugger%20with%20the%20cargo%20test%20suite/near/226313813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/using.20the.20vscode.20lldb.20debugger.20with.20the.20cargo.20test.20suite.html#226313813">(Feb 14 2021 at 16:46)</a>:</h4>
<p>I haven't used vscode in a long time, but I recall just editing the debug config to launch the test process.  You can find the process path by running <code>cargo test</code>, it should say something like <code>Running target/debug/deps/mytest-88b299c268784ee2</code>.</p>



<a name="226313819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/using%20the%20vscode%20lldb%20debugger%20with%20the%20cargo%20test%20suite/near/226313819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/using.20the.20vscode.20lldb.20debugger.20with.20the.20cargo.20test.20suite.html#226313819">(Feb 14 2021 at 16:46)</a>:</h4>
<p>oh I misread, you mean to follow cargo's own testsuite launching cargo</p>



<a name="226313897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/using%20the%20vscode%20lldb%20debugger%20with%20the%20cargo%20test%20suite/near/226313897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/using.20the.20vscode.20lldb.20debugger.20with.20the.20cargo.20test.20suite.html#226313897">(Feb 14 2021 at 16:48)</a>:</h4>
<p>What I would do in that case is run the one test like <code>cargo test --test testsuite -- thetestname</code>, then set up a debug session to run <code>target/debug/cargo</code> in the <code>target/cit/t0/foo</code> directory with the <code>CARGO_HOME</code> environment variable set to <code>target/cit/t0/home/.cargo</code>.</p>



<a name="226315208"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/using%20the%20vscode%20lldb%20debugger%20with%20the%20cargo%20test%20suite/near/226315208" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Brendan Cully <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/using.20the.20vscode.20lldb.20debugger.20with.20the.20cargo.20test.20suite.html#226315208">(Feb 14 2021 at 17:17)</a>:</h4>
<p>ah I see, basically debug cargo directly after getting the test suite to set up the project dir. Could do that, suppose I might as well just set up the test root by hand :)</p>



<a name="226315280"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/using%20the%20vscode%20lldb%20debugger%20with%20the%20cargo%20test%20suite/near/226315280" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Brendan Cully <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/using.20the.20vscode.20lldb.20debugger.20with.20the.20cargo.20test.20suite.html#226315280">(Feb 14 2021 at 17:19)</a>:</h4>
<p>I did end up trying gdb in VSCode with the Native Debug extension, which actually works, but the variable display is much lower quality. I guess maybe there isn't some silly trick, I'm just off the beaten path here a bit.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>